<script setup lang="ts">
import FinanciaYoyTab from '@/components/Echart/Table/FinanciaYoyTab.vue'
import FinanciaDiong from '@/components/Echart/Table/FinanciaDiong.vue'
import { reactive, watch, ref } from 'vue'
import { storeToRefs } from 'pinia'
import { useFinanceStore } from '@/stores/module/finance'
const FinanceStore = useFinanceStore() // 创建store实例
const { getIncomeQOQ } = storeToRefs(FinanceStore)
const barValues = getIncomeQOQ.value?.info[0]?.bar?.value
const lineValues = getIncomeQOQ.value?.info[0]?.line?.value
const subTitles = getIncomeQOQ.value?.sub_titles
const tableHeadData = reactive(getIncomeQOQ.value?.info[0]?.tableHeadData)
const tableBodyData = reactive(
  subTitles?.map((title, index) => ({
    id: index.toString(),
    name: title,
    valueDifference: barValues[index],
    YoYIncrease: lineValues[index],
  }))
)

const dialogVisible = ref(false)
const btn = () => {
  dialogVisible.value = true
}
</script>
<template>
  <card-box>
    <template v-slot:title>
      <h1>{{ getIncomeQOQ.title }}</h1>
    </template>
    <button
      @click="btn"
      class="see-more-btn"
      size="small"
      v-if="tableBodyData.length > 5"
    >
      {{ $t('bi_front_distributorseemore') }}
    </button>
    <FinanciaYoyTab
      :table-head-data="tableHeadData"
      :table-body-data="tableBodyData"
      v-if="tableBodyData.length && tableHeadData.length"
    />
    <div v-else class="default-img">
      <p>{{ $t('bi_common_nodata') }}</p>
    </div>
  </card-box>

  <el-dialog
    v-model="dialogVisible"
    width="50%"
    class="transactionData"
    style="background-color: rgba(11, 31, 86, 0.5)"
  >
    <FinanciaDiong
      :table-head-data="tableHeadData"
      :table-body-data="tableBodyData"
    />
  </el-dialog>
</template>
<style lang="scss" scoped>
.default-img {
  width: 100%;
  text-align: center;
  padding: 120px 0;
  background-image: url('@/assets/images/canvsimage/default.png');
  background-repeat: no-repeat;
  background-position: center;
  font-size: 16px;
  color: #00f6ff;
}

.see-more-btn {
  position: relative;
  z-index: 100;
  width: 100px;
  height: 25px;
  text-align: center;
  float: right;
  margin-top: -30px;
  font-size: 10px;
  background-color: rgba(0, 53, 171, 0.8);
  border: 1px solid #0b45ca;
  color: #00f6ff;
  cursor: pointer;
}
.dialog-fade-enter-active .el-dialog.transactionData {
  animation: tilt-in-left 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

@keyframes tilt-in-left {
  0% {
    -webkit-transform: rotateX(-30deg) translateX(-300px) skewX(-30deg);
    transform: rotateX(-30deg) translateX(-300px) skewX(-30deg);
    opacity: 0;
  }
  100% {
    -webkit-transform: rotateX(0deg) translateX(0) skewX(0deg);
    transform: rotateX(0deg) translateX(0) skewX(0deg);
    opacity: 1;
  }
}
</style>
